#include <iostream>
using namespace std;

int main()
{
  char input;
  cout << "Enter 8 binary digits:" << endl;
  cin >> input;
  bool a7 = (input == '1');
  cin >> input;
  bool a6 = (input == '1');
  cin >> input;
  bool a5 = (input == '1');
  cin >> input;
  bool a4 = (input == '1');
  cin >> input;
  bool a3 = (input == '1');
  cin >> input;
  bool a2 = (input == '1');
  cin >> input;
  bool a1 = (input == '1');
  cin >> input;
  bool a0 = (input == '1');

//  cin.flush();

  cout << "Enter another 8 binary digits:" << endl;
  cin >> input;
  bool b7 = (input == '1');
  cin >> input;
  bool b6 = (input == '1');
  cin >> input;
  bool b5 = (input == '1');
  cin >> input;
  bool b4 = (input == '1');
  cin >> input;
  bool b3 = (input == '1');
  cin >> input;
  bool b2 = (input == '1');
  cin >> input;
  bool b1 = (input == '1');
  cin >> input;
  bool b0 = (input == '1');

  bool carry = false;
  bool x;
  x = (a0 && !b0) || (!a0 && b0);
  bool out0 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a0 && b0);
  x = (a1 && !b1) || (!a1 && b1);
  bool out1 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a1 && b1);
  x = (a2 && !b2) || (!a2 && b2);
  bool out2 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a2 && b2);
  x = (a3 && !b3) || (!a3 && b3);
  bool out3 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a3 && b3);
  x = (a4 && !b4) || (!a4 && b4);
  bool out4 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a4 && b4);
  x = (a5 && !b5) || (!a5 && b5);
  bool out5 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a5 && b5);
  x = (a6 && !b6) || (!a6 && b6);
  bool out6 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a6 && b6);
  x = (a7 && !b7) || (!a7 && b7);
  bool out7 = (x && !carry) || (!x && carry);
  carry = (x && carry) || (a7 && b7);

  cout << "Answer is:" << endl;
  cout << out7 << out6 << out5 << out4 << out3 << out2 << out1 << out0 << endl;

  return 0;
}

